package com.wyx.controller;

import com.wyx.pojo.dto.LoginDto;
import com.wyx.pojo.dto.UserDto;
import com.wyx.pojo.result.Result;
import com.wyx.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;
//    查询用户合集
    @GetMapping("/list")
    public Result selectList() {

        List<UserDto> userDtos = userService.selectList();
        Result result = Result.success(userDtos);
        return result;
    }

    //判断是否允许登录
    @PostMapping("/login")
    public Result loginCheck(@RequestBody LoginDto loginDto){
        log.info("有用户登录传递的信息为:{}",loginDto.toString());
        Result result=userService.judge(loginDto);
        return result;
    }
}
